package demo1;

import demo1.EmptyException;
import demo1.MyArrayList;
import demo1.PosIllegality;

public class test {

    public static void main(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        try{
            myArrayList.add(0,11);
            myArrayList.add(1,21);
            myArrayList.add(2,31);
            myArrayList.add(3,41);
            myArrayList.add(4,51);
            myArrayList.add(5,66);
        }catch(PosIllegality e){
            e.printStackTrace();
            System.out.println("add-pos位置异常！");
        }catch (EmptyException e){
            e.printStackTrace();
        }//默认数组容量
        myArrayList.remove(51);
        myArrayList.display();

    }
    public static void main1(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(1);
        myArrayList.add(2);
        myArrayList.add(3);
        myArrayList.add(4);
        myArrayList.display();
        System.out.println(myArrayList.size());
        boolean ret = myArrayList.contains(20);
        System.out.println(ret);
        int ret1 = myArrayList.indexOf(1);
        System.out.println(ret1);
        System.out.println("=============");
        try{
            int i = myArrayList.get(3);
            System.out.println(i);
        }catch (EmptyException e){
            e.printStackTrace();
        }catch (PosIllegality e){
            e.printStackTrace();
        }

    }
}
